package p16.p1613;

import java.util.ArrayList;
import java.util.Iterator;

public class Text {
    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();
        Student student1 = new Student("wa", 1);
        Student student2 = new Student("gd", 2);
        Student student3 = new Student("dd", 7);
        Student student4 = new Student("bd", 5);
        students.add(student1);
        students.add(student2);
        students.add(student3);
        students.add(student4);

        for (Student student : students
                ) {
/*            System.out.println("student = " + student.get姓名());
            System.out.println("student = " + student.get年龄());*/
            System.out.println("student = " + student);
        }

        System.out.println("-----------------");

        for (int i = 0; i < students.size(); i++) {
            System.out.println(students.get(i));
        }
        System.out.println("-----------------");
        Iterator<Student> iterator = students.iterator();
        while (iterator.hasNext()) {
            System.out.println("iterator = " + iterator.next());
        }
        System.out.println("-----------------");
        for (Iterator<Student> iterator1 = students.iterator(); iterator1.hasNext(); ) {
            System.out.println("iterator1 = " + iterator1.next());
        }
    }
}
